package com.lhgray.sglhome.common;

import android.content.Context;
import android.content.Intent;

import androidx.activity.result.contract.ActivityResultContract;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.king.camera.scan.CameraScan;
import com.lhgray.sglhome.presentation.ui.activity.ScanActivity;

/**
 * 作者：lhgray on 2025/3/31.
 * 邮箱：lhgray@163.com
 * 文件：com.lhgray.sglhome.screen
 */
public class ScanQRContract extends ActivityResultContract<Void, String> {
    @NonNull
    @Override
    public Intent createIntent(@NonNull Context context, Void input) {
        return new Intent(context, ScanActivity.class);
    }

    @Override
    public String parseResult(int resultCode, @Nullable Intent intent) {
        if (intent != null) {
            return intent.getStringExtra(CameraScan.SCAN_RESULT);
        }
        return "";

    }
}